package com.cxria.springboottest.web

import com.cxria.springboottest.dto.Status
import com.cxria.springboottest.entity.User
import com.cxria.springboottest.enums.StatusCodeEnum
import com.cxria.springboottest.enums.StatusMsgEnum
import com.cxria.springboottest.service.UserService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller
import org.springframework.ui.Model
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody

import javax.servlet.http.HttpServletRequest;

@Controller
@EnableAutoConfiguration
@RequestMapping('/user')
class UserController {

    @Autowired
    private UserService userService;

    //@PreAuthorize("hasRole('admin')")
    @GetMapping('/show')
    @ResponseBody
    User user(){
        userService.getUser('谢飞鸿')
    }

    @GetMapping('/info')
    String info(Model model){
        User user = userService.getUser('谢飞鸿')
        model.addAttribute(user)
        'index'
    }

    @GetMapping('/login')
    String login(){
        'login'
    }

    /*@PostMapping('/logout')
    String logout(){
        'login'
    }*/

}


